package com.ydc.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ydc.mapper.AdminMapper;
import com.ydc.pojo.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import java.util.UUID;

@Service
public class AdminServiceImpl implements AdminService{

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public String selectAdmin(Admin admin) {
        String md5Pass = DigestUtils.md5DigestAsHex(admin.getPassword().getBytes());
        System.out.println(md5Pass);
        admin.setPassword(md5Pass);
        Admin one = adminMapper.selectOne(new QueryWrapper<Admin>(admin));
        String token = UUID.randomUUID().toString()
                .replace("-","");
        return one==null ? "" : token;
    }
}
